package com.omp.ocr.ocr;

import android.app.Activity;
import android.content.Intent;
import android.util.Log;

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.onemore.sfpt.IDCardActivity;

/**
 * This class echoes a string called from JavaScript.
 */
public class ocr extends CordovaPlugin {

    private String TAG = "ocr";

    private Activity activity;

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

        this.activity = this.cordova.getActivity();

        if (action.equals("callNativeModule")) {
            Log.e(TAG,"execute-callNativeModule");
            this.callNativeModule("", callbackContext);
            return true;
        }
        return false;
    }

    private void callNativeModule(String name, CallbackContext callbackContext) {
        Intent intent = new Intent(activity, IDCardActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.getApplicationContext().startActivity(intent);
    }
}
